package repository

import "eat-every-day/internal/model"

type IUsersRepo interface {
	SelectUsersByUsername(username string) (*model.Users, error)
	Create(users *model.Users) error
}

type UsersRepo struct {
	MySqlDataBase *model.DataBase
}

func (repo *UsersRepo) SelectUsersByUsername(username string) (*model.Users, error) {
	user := &model.Users{}
	err := repo.MySqlDataBase.DB.Debug().Where("username = ?", username).Find(&user).Error
	return user, err
}

func (repo *UsersRepo) Create(users *model.Users) error {
	err := repo.MySqlDataBase.DB.Debug().Create(&users).Error
	return err
}
